Skip to content

Return 400 instead of 404 for a malformed date query parameter (fixes #159) - #562

Open
iacsha wants to merge 2 commits into
OpenIntegrationEngine:mainfrom
iacsha:fix/159-date-param-400
Open

iacsha wants to merge 2 commits into
OpenIntegrationEngine:mainfrom
iacsha:fix/159-date-param-400

Conversation

@iacsha

@iacsha iacsha commented Nov 4, 2026

Copy link
Copy Markdown

Return 400 instead of 404 for a malformed date query parameter (fixes #159)

Problem

GET /api/channels/{channelId}/messages (and the other message endpoints) take
startDate/endDate as @QueryParam Calendar, converted by
CalendarParamConverterProvider. On a malformed date, fromString throws
ProcessingException, which Jersey surfaces as 404 Not Found:

GET /api/channels/{id}/messages?startDate=1985   ->   404 { "message": "Not Found" }

404 is misleading for a bad parameter value — the caller should get a 400 that says
what was wrong.

Fix

Throw BadRequestException (400) from the converter, with a message naming the value and
the expected format:

} catch (DateTimeParseException e) {
    throw new BadRequestException("Invalid date '" + value + "'. Expected format yyyy-MM-dd'T'HH:mm:ss.SSSZ, for example 1985-10-26T09:00:00.000-0700.", e);
}

JAX-RS honors a WebApplicationException thrown from a ParamConverter (and no
ExceptionMappers are registered that would override it), so the response status is 400.
Valid dates are unaffected.

Tests

CalendarParamConverterProviderTest:

  • null returns null
  • a valid date round-trips (fromString then toString)
  • a malformed date throws BadRequestException with status 400

./gradlew :server:test --tests "*CalendarParamConverterProviderTest*" → 3 tests, 0 failures.

Note on verification

The project has no Jersey HTTP test harness, so this is verified at the converter level —
the same approach as the existing MetaDataSearchParamConverterProviderTest. The
HTTP-level 400 follows from JAX-RS WebApplicationException handling as described above.

@NicoPiel NicoPiel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

License file header, otherwise LGTM.

@tonygermano
tonygermano force-pushed the fix/159-date-param-400 branch from f89224f to 1468ea2 Compare November 4, 2026 22:20
iacsha added a commit to iacsha/engine that referenced this pull request Nov 5, 2026
Per review feedback on OpenIntegrationEngine#562, replace the copied Mirth Corporation
boilerplate header with the SPDX form used for new files.
@iacsha

iacsha commented Nov 5, 2026

Copy link
Copy Markdown
Author

Thanks @NicoPiel and @tonygermano. Switched the new test file to the SPDX header, using the collective Open Integration Engine Contributors form (no per-file email). Done in 6abb13b.

…penIntegrationEngine#159)

CalendarParamConverterProvider threw ProcessingException on an unparseable startDate/endDate, which Jersey surfaced as 404. Throw BadRequestException (400) with the value and expected format so the caller learns why the request failed.

Signed-off-by: iacsha <122627209+iacsha@users.noreply.github.com>
Per review feedback on OpenIntegrationEngine#562, replace the copied Mirth Corporation
boilerplate header with the SPDX form used for new files.

Signed-off-by: iacsha <122627209+iacsha@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

Test Results

  142 files  +1    142 suites  +1   4m 3s ⏱️ + 1m 4s
  922 tests +3    922 ✅ +3  0 💤 ±0  0 ❌ ±0 
1 054 runs  +3  1 048 ✅ +3  6 💤 ±0  0 ❌ ±0 

Results for commit 4a48ac6. ± Comparison against base commit 892e33f.

@mgaffigan mgaffigan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Open Integration Engine Contributors" is not a legal entity. Until you sign an ECA, you individually retain copyright and are issuing an MPL-2 license. Approval since this has happened otherwise, and your git commit already signs your name and email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] HTTP 404 error (Not Found) reported for unrecognized date input to API

4 participants